/************************************************************************
 * Implementation code for procedure - 'procedure1'
 *
 *
 * @return - invocationResult
 */
 
var queryAllSQL = WL.Server.createSQLStatement("select * from daily_thinking");
var queryByDateSQL = WL.Server.createSQLStatement("select * from daily_thinking where write_date = ?");
var updateSQL = WL.Server.createSQLStatement("update daily_thinking set challenge = ?, action = ? ,isShared =? where id = ?");
var deleteSQL = WL.Server.createSQLStatement("delete from daily_thinking where id = ?");
var saveSQL = WL.Server.createSQLStatement("insert into daily_thinking(user_name,challenge,action,write_date) values(?,?,?,curdate())");
function queryAll(param) {
	return WL.Server.invokeSQLStatement({
		preparedStatement : queryAllSQL,
		parameters : []
	});
}
 
function queryByDate(param) {
	return WL.Server.invokeSQLStatement({
		preparedStatement : queryByDateSQL,
		parameters : [param]
	});
}

function save(userName,challenge,action) {
	return WL.Server.invokeSQLStatement({
		preparedStatement : saveSQL,
		parameters : [userName,challenge,action]
	});
}


function update(id,challenge,action,isShared) {
	return WL.Server.invokeSQLStatement({
		preparedStatement : updateSQL,
		parameters : [challenge,action,isShared,id]
	});
}

function remove(param) {
	return WL.Server.invokeSQLStatement({
		preparedStatement : deleteSQL,
		parameters : [param]
	});
}